import React from "react"
import NormalHeader from "../../../components/shop_components/NormalHeader"
import CityList from "../../../components/shop_components/CityList"
import CurrentCity from "../../../components/shop_components/CurrentCity"

import { connect } from "react-redux";
import * as cityActions from "../../../redux/actions/city"
import { bindActionCreators } from "redux"
import { withRouter } from "react-router-dom"

class City extends React.Component{

	render(){
		// console.log(this.props.location)
		let citys = ['北京','成都','长沙','武汉','郑州','西安','太原','贵州','洛阳'];
		return(
			<div>
				<NormalHeader title="城市选择" />
				<CurrentCity cityName={this.props.getCityinfo.cityName} />
				<CityList data={ citys } />
			</div>
		)
	}
}

// 读
function mapStateToprops(state){
	return {
		getCityinfo:state.cityinfo
	}
}

// 写
function mapDispatchToprops(dispatch){
	return {
		setCityinfo: bindActionCreators(cityActions,dispatch)
	}
}

export default withRouter(connect(
	mapStateToprops,
	mapDispatchToprops
)(City))